#include<bits/stdc++.h>
using namespace std;
const int maxn = 100007;
int a[maxn];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, m; cin>>n>>m;
    for(int i=1; i<=n; ++i) {
        cin>>a[i];
        a[i] += a[i-1];
    }
    while(m--) {
        int l, r; cin>>l>>r;
        cout<<a[r] - a[l-1]<<endl;
    }
}
